package com.ruoyi.student.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.student.domain.SysUserTeacher;
import com.ruoyi.student.mapper.SysUserTeacherMapper;
import com.ruoyi.student.service.ISysUserTeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SysUserTeacherServiceImpl extends ServiceImpl<SysUserTeacherMapper,SysUserTeacher> implements ISysUserTeacherService {


    @Resource
    private SysUserTeacherMapper sysTeacherMapper;

    /**
     * 根据关键词查询老师列表
     *
     * @param keyword
     * @return
     */
    @Override
    public List<SysUserTeacher> searchTeacherList(String keyword) {
        LambdaQueryWrapper<SysUserTeacher> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysUserTeacher::getDelFlag, "0");
        lambdaQueryWrapper.eq(SysUserTeacher::getStatus, "0");
        lambdaQueryWrapper.eq(SysUserTeacher::getUserType, "00");
        if (!StringUtils.isEmpty(keyword)) {
            lambdaQueryWrapper.and(wrapper -> wrapper.like(SysUserTeacher::getUserName, keyword).or().like(SysUserTeacher::getNickName, keyword));
        }
        return sysTeacherMapper.selectList(lambdaQueryWrapper);
    }
}
